<!--
 * @Descripttion: 
 * @version: @ 1.0.0
 * @Author: 朱江洲
 * @Date: 2021-10-12 10:36:00
 * @LastEditors: 朱江洲
 * @LastEditTime: 2022-05-06 17:48:35
-->
<template>
  <div class="app-container">
    <div class="chioose-header">
      <div class="chioose-header-left">
        <div
          class="tab-title"
          v-for="(item, index) in tabList"
          :key="index"
          :class="item.id === active1 ? 'active1' : ''"
          @click="changeTab(item)"
        >
          {{ item.label }}
        </div>
      </div>
      <div class="chioose-header-right">
        <div>
          订单类型：
          <el-select
            v-model="type"
            placeholder="请选择订单类型"
            clearable
            filterable
          >
            <el-option
              v-for="item in options"
              :key="item.value"
              :label="item.label"
              :value="item.value"
            >
            </el-option>
          </el-select>
        </div>
        <div>
          <el-button
            type="primary"
            size="default"
            @click="$router.push('/invoiceast')"
          >
            开具发票
          </el-button>
        </div>
      </div>
    </div>
    <div class="table-size">
      <table-header></table-header>
      <all-order :orderData="orderData"></all-order>
    </div>
    <!-- 分页器 -->
    <el-pagination
      prev-text="上一页"
      next-text="下一页"
      background
      :page-size="pageSize"
      :page-sizes="[10, 20, 30, 40, 50, 100]"
      @size-change="handleSizeChange"
      @current-change="handleCurrentChange"
      :current-page="pageNum"
      layout=" ->,total, sizes,prev, pager, next, jumper "
      :total="total"
    >
    </el-pagination>
  </div>
</template>

<script>
import { getList } from "@/api/IndividualUser/myOrder";
import AllOrder from "./conponments/myOrder/allOrder.vue";
import tableHeader from "./conponments/myOrder/tableHeader.vue";
export default {
  components: { tableHeader, AllOrder },
  data() {
    return {
      options: [{ value: 0, label: "全部订单" }],
      orderData: [],
      pageNum: 1,
      total: 0,
      pageSize: 10,
      type: "",
      status: "",
      active1: 0,
      tabList: [
        {
          id: 0,
          label: "全部订单",
        },
        {
          id: 1,
          label: "待支付",
        },
        {
          id: 2,
          label: "已完成",
        },
        {
          id: 3,
          label: "已取消",
        },
      ],
    };
  },
  created() {
    this.getList();
  },
  methods: {
    handleSizeChange(val) {
      this.pageSize = val;
      this.pageNum = 1;
      this.getList();
    },
    // 分页器
    handleCurrentChange(val) {
      this.pageNum = val;
      this.getList();
    },
    // 获取订单
    getList() {
      getList({
        type: this.type,
        status: this.status,
        pageNum: this.pageNum,
        pageSize: this.pageSize,
      }).then((res) => {
        console.log(res);
        this.orderData = res.rows;
        this.total = res.total;
      });
    },
    changeTab(item) {
      this.active1 = item.id;
      if (item.id == 0) {
        this.status = "";
        this.getList();
      } else if (item.id == 1) {
        this.status = 1;
        this.getList();
      } else if (item.id == 2) {
        this.status = 2;
        this.getList();
      } else {
        this.status = 3;
        this.getList();
      }
    },
  },
};
</script>

<style lang="less" scoped>
.chioose-header {
  width: 100%;
  height: 64px;
  line-height: 64px;
  border-bottom: 1px solid #ececec;
  display: flex;
  justify-content: space-between;
}
.chioose-header-left {
  display: flex;
}
.chioose-header-right {
  .el-button {
    margin-left: 20px;
  }
  display: flex;
}
.tab-title {
  display: flex;
  margin-left: 44px;
  cursor: pointer;
}
.active1 {
  border-bottom: 2px solid #1267fa;
  color: #1267fa;
}
.table-size {
  height: 79vh;
  border-bottom: 1px solid #ececec;
  overflow-y: auto;
}
.el-pagination {
  margin-top: 24px;
  /deep/ .el-pagination__total {
    width: 40px;
    height: 40px;
    line-height: 40px;
    text-align: center;
    margin-right: 25px;
  }
  /deep/ .btn-prev {
    width: 80px;
    height: 40px;
    text-align: center;
  }
  /deep/ .btn-next {
    width: 80px;
    height: 40px;
    text-align: center;
  }
  /deep/ .number {
    width: 40px;
    height: 40px;
    line-height: 40px;
    text-align: center;
  }
  /deep/ .el-input__inner {
    // width: 40px;
    height: 40px;
    line-height: 40px;
    text-align: center;
  }
  /deep/ .more {
    width: 40px;
    height: 40px;
    line-height: 40px;
    text-align: center;
  }
  /deep/ .el-pagination__jump {
    .el-input__inner {
      width: 40px;
      height: 40px;
    }
  }
}
</style>